﻿using Demo.ProductService.Services;
using Demo.ProductService.Services.Dtos;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;

namespace Demo.WebSite.Controllers
{

    [ApiController]
    [Route("api/app/test")]
    public class TestController : AbpController
    {
        /// <summary>
        /// 依赖注入IProductService
        /// </summary>
        public IProductService productService { get; set; }

        /// <summary>
        /// 添加商品方法
        /// </summary>
        /// <returns></returns>
        [HttpPost("AddProduct")]
        public async Task<ProductDto> AddProduct(ProductDto productDto)
        {
            // 1、实现添加商品
            return await productService.CreateAsync(productDto);
        }
        /// <summary>
        /// GetProducts
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetProducts")]
        public async Task<List<ProductDto>> GetProductsAsync()
        {
            return await productService.GetProductsAsync();
        } 
    }
}
